package com.example.human_resource_management.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.human_resource_management.entry.dto.PositionDepartmentDto;
import com.example.human_resource_management.entry.po.Position;
import com.example.human_resource_management.service.PositionService;
import com.example.human_resource_management.mapper.PositionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @author Lenovo
* @description 针对表【position(职位表)】的数据库操作Service实现
* @createDate 2025-06-09 08:49:10
*/
@Service
public class PositionServiceImpl extends ServiceImpl<PositionMapper, Position>
    implements PositionService{
    @Autowired
    private PositionMapper positionMapper;

    @Override
    public List<PositionDepartmentDto> selectPositionDepartmentList() {
        return positionMapper.selectPositionDepartmentList();
    }

    @Override
    public PositionDepartmentDto selectPositionDepartmentById(Long posId) {
        return positionMapper.selectPositionDepartmentById(posId);
    }

    @Override
    public boolean addPosition(Position position) {
        return save(position);
    }

    @Override
    public boolean updatePosition(Position position) {
        return updateById(position);
    }

    @Transactional
    @Override
    public boolean deletePosition(Long posId) {
        // 检查是否有员工关联此职位
        // 如果有，需要先处理员工关联
        // 这里简化处理，直接删除职位

        return removeById(posId);
    }
}




